const { Order } = require('@/models/product');
const getOrders = async (req, res) => {
  const orders = await Order.getOrders();
  res.json(orders);
}
const getOrderById = async (req, res) => {
  const { id } = req.params;
  const order = await Order.getOrderById(id);
  res.json(order);
}
const updateStatus = async (req, res) => {
  const { id } = req.params;
  const { status } = req.body;
  const order = await Order.updateStatus(id, status);
  res.json(order);
}
const refundOrder = async (req, res) => {
  const { id } = req.params;
  const order = await Order.refundOrder(id);
  res.json(order);
}
const exportOrders = async (req, res) => {
  const { status } = req.query;
  const orders = await Order.exportOrders(status);
  res.json(orders);
}

module.exports = {
  getOrders,
  getOrderById,
  updateStatus,
  refundOrder,
  exportOrders
}
